<template>
	<view class="orgdetail-container">
		<!-- 自定义导航栏 -->
		<MyHeader>
			<template #title>
				<view>{{detail.base_info.name}}</view>
			</template>
		</MyHeader>

		<!-- 背景图 -->
		<view class="bg">
			<image src="/static/Organization/bg.png" mode="widthFix"></image>
		</view>

		<!-- 金刚区 -->
		<view class="nav">
			<navigator class="item" :url="'/pages/synopsis/synopsis?detail='+JSON.stringify(detail.base_info)">
				<view class="img">
					<image src="/static/Organization/nav1.png" mode="widthFix"></image>
				</view>
				<view class="title">简介</view>
			</navigator>
			<navigator class="item" :url="'/pages/Member/Member?detail='+JSON.stringify(detail.members.list)">
				<view class="img">
					<image src="/static/Organization/nav2.png" mode="widthFix"></image>
				</view>
				<view class="title">成员</view>
			</navigator>
			<navigator class="item"
				:url="'/pages/activityList/activityList?detail='+JSON.stringify(detail.activity.list)+'&title=组织活动'">
				<view class="img">
					<image src="/static/Organization/nav3.png" mode="widthFix"></image>
				</view>
				<view class="title">活动</view>
			</navigator>
			<navigator class="item" :url="'/pages/post/postList?detail='+JSON.stringify(detail.posts.list)">
				<view class="img">
					<image src="/static/Organization/nav4.png" mode="widthFix"></image>
				</view>
				<view class="title">趣帖</view>
			</navigator>
			<view class="item" @tap="kfing">
				<view class="img">
					<image src="/static/Organization/nav5.png" mode="widthFix"></image>
				</view>
				<view class="title">管理</view>
			</view>
		</view>

		<!-- 通知 -->
		<u-collapse :border="false">
			<u-collapse-item class="title" title="通知" :border="false">
				<text class="content">{{detail.base_info.notice}}</text>
			</u-collapse-item>
		</u-collapse>

		<!-- 组织成员 -->
		<navigator class="members" :url="'/pages/Member/Member?detail='+JSON.stringify(detail.members.list)">
			<view class="t">
				<view class="title">组织成员</view>
				<view class="right">
					<view>{{detail.members.total}}</view>
					<view>
						<u-icon name="arrow-right" size="36rpx" color="#999"></u-icon>
					</view>
				</view>
			</view>
			<view class="b">

				<scroll-view class="scroll-view_H" :scroll-x="true" enable-flex>
					<view class="item" v-for="item in detail.members.list" :key="item.user_id">
						<view class="img">
							<image :src="item.avatar" mode="widthFix"></image>
						</view>
						<view class="name">{{item.username}}</view>
					</view>
				</scroll-view>
			</view>
		</navigator>

		<!-- 活动 -->
		<navigator class="activity" v-if="detail.activity.list.length>0"
			:url="'/pages/activityList/activityList?detail='+JSON.stringify(detail.activity.list)+'&title=组织活动'">
			<view class="t">
				<view class="title">活动</view>
				<view class="right">
					<view>{{detail.activity.total}}</view>
					<view>
						<u-icon name="arrow-right" size="36rpx" color="#999"></u-icon>
					</view>
				</view>
			</view>
			<view class="b">
				<view class="info">
					<view class="l">
						<view class="title-a">{{detail.activity.list[0].name}}</view>
						<view class="content">{{detail.activity.list[0].username}}</view>
						<view class="content">{{detail.activity.list[0].start_at}}至{{detail.activity.list[0].end_at}}</view>
					</view>
					<view class="img-a">
						<image :src="detail.activity.list[0].image_path" mode="widthFix"></image>
					</view>
				</view>
				<view class="show">{{detail.activity.list[0].signup_status_show}}</view>
			</view>
		</navigator>

		<!-- 帖子 -->
		<navigator class="posts" v-if="detail.posts.list.length>0"
			:url="'/pages/post/postList?detail='+JSON.stringify(detail.posts.list)">
			<view class="t">
				<view class="title">帖子</view>
				<view class="right">
					<view>{{detail.posts.total}}</view>
					<view>
						<u-icon name="arrow-right" size="36rpx" color="#999"></u-icon>
					</view>
				</view>
			</view>
			<view class="b">
				<view class="info">
					<view class="l">
						<view class="title-p">{{detail.posts.list[0].title}}</view>
						<view class="content">已上传：0</view>
						<view class="content">{{detail.posts.list[0].start_at}}至{{detail.posts.list[0].end_at}}</view>
					</view>
					<view class="img-p">
						<image :src="detail.posts.list[0].image" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</navigator>

		<!-- 底部按钮 -->
		<BottomButton @setHandleBtn="getHandleBtn">
			<template>
				<view>申请加入组织</view>
			</template>
		</BottomButton>
	</view>
</template>

<script>
	import MyHeader from '@/componets/MyHeader/MyHeader'
	import BottomButton from '@/componets/BottomButton/BottomButton.vue'
	export default {
		data() {
			return {
				id: '',
				detail: {
					members: {
						list: []
					},
					activity: {
						list: []
					},
					posts: {
						list: []
					}
				},
			}
		},
		methods: {

			/**
			 * 开发中
			 */
			kfing() {
				uni.showToast({
					title: '开发中敬请期待...',
					icon: 'none'
				})
				return
				uni.navigateTo({
					url: '/pages/orgManager/orgManager?id=' + this.detail.base_info.id
				})
			},

			/**
			 * 申请加入组织
			 */
			getHandleBtn() {
				this.$request.post({
					url: '/api/organization/join',
					data: {
						organization_id: this.detail.base_info.id
					},
					success: res => {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},

			/**
			 * 获取组织详情
			 */
			getOrgDetail() {
				this.$request.post({
					url: '/api/organization/detail',
					data: {
						id: this.id
					},
					success: res => {
						if (res.code != 200) return uni.showToast({
							title: res.msg,
							icon: 'none'
						})
						this.detail = res.result
						console.log(this.detail.members, 'this.detail.members')
					}
				})
			}
		},
		onLoad(options) {
			if (!options.id) return uni.navigateBack()
			this.id = options.id
			this.getOrgDetail()
		},
		components: {
			MyHeader,
			BottomButton
		}
	}
</script>

<style lang="less" scoped>
	.orgdetail-container {
		width: 100%;
		min-height: 100vh;
		background-color: #F6F6F6;
		overflow: hidden;
		position: relative;
		z-index: 9;
		padding-bottom: 258rpx;
		box-sizing: border-box;

		.bg {
			width: 1154rpx;
			height: 452rpx;
			position: absolute;
			top: -90rpx;
			left: 50%;
			transform: translateX(-50%);
			z-index: -1;

			>image {
				width: 100%;
			}
		}

		.nav {
			width: 710rpx;
			height: 200rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			overflow: hidden;
			display: flex;
			justify-content: space-evenly;
			align-items: center;
			margin: 40rpx auto 0;

			>.item {
				>.img {
					width: 70rpx;
					height: 70rpx;

					>image {
						width: 100%;
					}
				}

				>.title {
					font-size: 28rpx;
					font-family: Source Han Sans CN-Regular, Source Han Sans CN;
					font-weight: 400;
					color: #333333;
					line-height: 28rpx;
					margin-top: 24rpx;
				}
			}
		}

		/deep/.u-collapse {
			width: 710rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			opacity: 1;
			margin: 20rpx auto 0;
			overflow: hidden;

			.u-cell__body {
				padding: 20rpx;
			}

			.title {
				font-size: 28rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #333333;
				line-height: 28rpx;
			}

			.content {
				font-size: 28rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #666666;
				line-height: 48rpx;
				letter-spacing: 1px;
			}
		}

		.members,
		.activity,
		.posts {
			width: 710rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			opacity: 1;
			margin: 20rpx auto 0;

			>.t {
				width: 100%;
				padding: 20rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-bottom: 2rpx solid #f1f1f1;

				>.title {
					font-size: 28rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #333333;
					line-height: 28rpx;
				}

				>.right {
					font-size: 28rpx;
					font-family: Source Han Sans CN-Regular, Source Han Sans CN;
					font-weight: 400;
					color: #999999;
					line-height: 44rpx;
					display: flex;
					align-items: center;
				}
			}

			>.b {
				width: 100%;
				padding: 20rpx;
				box-sizing: border-box;
				position: relative;

				.show {
					position: absolute;
					left: 0;
					bottom: 0;
					width: 140rpx;
					height: 48rpx;
					background: #275BA8;
					border-radius: 0rpx 16rpx 0rpx 16rpx;
					opacity: 0.2;
					font-size: 24rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #275BA8;
					line-height: 34rpx;
				}

				.info {
					width: 100%;
					height: 100%;
					display: flex;
					justify-content: space-between;
					align-items: center;

					>.l {
						flex: 1;
						height: 100%;
						margin-right: 20rpx;

						>.title-a {
							font-size: 32rpx;
							font-family: Source Han Sans CN-Medium, Source Han Sans CN;
							font-weight: 500;
							color: #333333;
							line-height: 46rpx;
							width: 100%;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						>.title-p {
							font-size: 32rpx;
							font-family: Source Han Sans CN-Medium, Source Han Sans CN;
							font-weight: 500;
							color: #333333;
							line-height: 46rpx;
							width: 100%;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
						}

						>.content {
							font-size: 24rpx;
							font-family: Source Han Sans CN-Regular, Source Han Sans CN;
							font-weight: 400;
							color: #9C9C9C;
							line-height: 34rpx;
							margin-top: 20rpx;
						}
					}

					>.img-a {
						width: 200rpx;
						height: 200rpx;
						border-radius: 20rpx;
						overflow: hidden;

						image {
							width: 100%;
						}
					}

					>.img-p {
						width: 270rpx;
						height: 200rpx;
						border-radius: 20rpx;
						overflow: hidden;

						image {
							width: 100%;
						}
					}
				}

				.scroll-view_H {
					width: 100%;
					white-space: nowrap;
					display: flex;
					align-items: center;

					.item {
						display: flex;
						flex-direction: column;
						align-items: center;
						margin-right: 24rpx;

						>.img {
							width: 92rpx;
							height: 92rpx;
							border-radius: 50%;
							overflow: hidden;

							>image {
								width: 100%;
							}
						}

						>.name {
							margin-top: 14rpx;
							font-size: 24rpx;
							font-family: Source Han Sans CN-Regular, Source Han Sans CN;
							font-weight: 400;
							color: #333333;
							line-height: 28rpx;
						}
					}
				}


			}
		}
	}
</style>